#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, m;
int a[N], b[N];
int pos[N], l[1005], r[1005], d[1005];
void init() {
  int k = sqrt(n);
  rep(i, 1, n) pos[i] = (i - 1) / k + 1;
  int cnt = pos[n];
  rep(i, 1, cnt) {
    l[i] = (i - 1) * k + 1;
    r[i] = i * k;
  }
  r[cnt] = n;
  rep(i, 1, n) b[i] = a[i];
  rep(i, 1, cnt) sort(b + l[i], b + r[i] + 1);
}
void update_inb(int L, int R, int x) {
  int id = pos[L];
  rep(i, L, R) a[i] += x;
  rep(i, l[id], r[id]) b[i] = a[i];
  sort(b + l[id], b + r[id] + 1);
}
void update(int L, int R, int x) {
  int id1 = pos[L], id2 = pos[R];
  if (id1 == id2) {
    update_inb(L, R, x);
    return;
  }
  update_inb(L, r[id1], x), update_inb(l[id2], R, x);
  rep(i, id1 + 1, id2 - 1) d[i] += x;
}
int query_inb(int L, int R, int x) {
  int res = 0;
  int id = pos[L];
  rep(i, L, R) if (a[i] + d[id] >= x) res++;
  return res;
}
int query(int L, int R, int x) {
  int id1 = pos[L], id2 = pos[R];
  if (id1 == id2) return query_inb(L, R, x);
  int res = 0;
  res = query_inb(L, r[id1], x) + query_inb(l[id2], R, x);
  rep(i, id1 + 1, id2 - 1) res +=
      b + r[i] + 1 - lower_bound(b + l[i], b + r[i] + 1, x - d[i]);
  return res;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  init();
  while (m--) {
    char op;
    int L, R, x;
    cin >> op >> L >> R >> x;
    if (op == 'M')
      update(L, R, x);
    else
      cout << query(L, R, x) << endl;
  }
  return 0;
}